import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import elementui from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
//导入echarts数据库可视化 
import * as echarts from 'echarts'; 
//将echarts挂载至Vue属性中，属性名$echarts 
Vue.prototype.$echarts = echarts;

axios.defaults.baseURL = 'http://127.0.0.1:5000'
Vue.prototype.$http = axios

Vue.config.productionTip = false

Vue.use(elementui)
//前置路由守卫，判断路由权限
router.beforeEach((to,from,next)=>{
  const { role } = to.meta;
  if(role){
  const admin = JSON.parse(localStorage.getItem('admin'))
  if(role != admin.role){
  alert('您无权访问！');
  }else{
  next()
  }
  }else{
  next();
  } 
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
